package com.woniuxy01;

class Aaa{
    public  void test(){
        System.out.println("aaa");
    }
}
class Bbb extends Aaa{

    public void test(){
        System.out.println("bbb");
    }
}

public class Test02 {
    public static void main(String[] args) {
       Aaa aaa=new Aaa();
       Bbb bbb=new Bbb();
       //向上转型
//       aaa=bbb;
        //向下转型,
        aaa=bbb;
        System.out.println("aaa instanceof Bbb="+(aaa instanceof Bbb));
        if(aaa instanceof Bbb){
            System.out.println("兼容类型，可以转换");
            bbb= (Bbb) aaa;
        }else{
            System.out.println("不是兼容类型，不能转换");
        }

    }
}
